package cn.demo.um.service.impl;

import java.util.List;
import com.mybatisflex.core.paginate.Page;
import cn.demo.common.core.page.PageQuery;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import cn.demo.um.mapper.UmUserFocusMapper;
import cn.demo.um.domain.UmUserFocus;
import cn.demo.um.service.IUmUserFocusService;

/**
 * 用户关注列Service业务层处理
 *
 * @author xtjun
 * @date 2024-06-06
 */
@Service
public class UmUserFocusServiceImpl extends ServiceImpl<UmUserFocusMapper, UmUserFocus> implements IUmUserFocusService {
    @Resource
    private UmUserFocusMapper umUserFocusMapper;
    /**
     * 查询用户关注列
     *
     * @param userId 用户关注列主键
     * @return 用户关注列
     */
    @Override
    public UmUserFocus selectUmUserFocusByUserId(String userId) {
        return umUserFocusMapper.selectOneById(userId);
    }

    /**
     * 查询用户关注列列表
     *
     * @param umUserFocus 用户关注列
     * @return 用户关注列
     */
    @Override
    public Page<UmUserFocus> selectUmUserFocusPage(UmUserFocus umUserFocus, PageQuery pageQuery) {
        return umUserFocusMapper.paginate(pageQuery.build(), QueryWrapper.create(umUserFocus));
    }
    @Override
    public List<UmUserFocus> selectUmUserFocusList(UmUserFocus umUserFocus) {
        return umUserFocusMapper.selectListByQuery(QueryWrapper.create(umUserFocus));
    }

    /**
     * 新增用户关注列
     *
     * @param umUserFocus 用户关注列
     * @return 结果
     */
    @Override
    public int insertUmUserFocus(UmUserFocus umUserFocus) {
        return umUserFocusMapper.insert(umUserFocus);
    }

    /**
     * 修改用户关注列
     *
     * @param umUserFocus 用户关注列
     * @return 结果
     */
    @Override
    public int updateUmUserFocus(UmUserFocus umUserFocus) {
        return umUserFocusMapper.update(umUserFocus);
    }

    /**
     * 批量删除用户关注列
     *
     * @param userIds 需要删除的用户关注列主键
     * @return 结果
     */
    @Override
    public int deleteUmUserFocusByUserIds(List<String> userIds) {
        return umUserFocusMapper.deleteBatchByIds(userIds);
    }

    /**
     * 删除用户关注列信息
     *
     * @param userId 用户关注列主键
     * @return 结果
     */
    @Override
    public int deleteUmUserFocusByUserId(String userId) {
        return umUserFocusMapper.deleteById(userId);
    }
}
